home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / bt108.zip / BT.ASM next >
Assembly Source File  |  1994-01-25  |  10KB  |  399 lines

  1.     page    ,132
  2.     title    BootThru  - v1.06
  3. ; For Borland:
  4. ;    tasm bt
  5. ;    tlink -t bt
  6. ;
  7. ;------------------------------------------------------------------------
  8. ;
  9. ;  BootThru  -    Copyright (c) Bill Gibson - 1987
  10. ;        Lathrup Village, Mi 48076
  11. ;
  12. ;  Ver. 1.00 - Initial version             (not rlsd) -  01/11/87
  13. ;    1.01 - revised code structure              "     -  01/25/87
  14. ;    1.02 - revised Modify Proc              "     -  02/01/87
  15. ;    1.03 - enhanced error message output          "     -  02/06/87
  16. ;    1.04 - revised Print Proc          released  -  02/07/87
  17. ;    1.05 - fix incompatibility plbm             -  02/09/87
  18. ;    1.06 - fix problem with DOS 3.2             -  05/31/87
  19. ;           DOS 3.2 believes the boot sector's information about
  20. ;           the disk in the drive.  v1.05 only worked with 360K disks.
  21. ;           v1.06 now reads the old boot sector and transfers the
  22. ;           information into the new boot sector.
  23. ;    1.07 - Took out waits
  24. ;        Fixed up boot header to be like DOS 4.0 & 5.0
  25. ;    1.08 - Minor changes
  26. ;
  27. ;
  28. ;  For Public Domain Use.  Not for Sale or Hire.
  29. ;  Last modified by:
  30. ;    Ray Van Tassle
  31. ;    1020 Fox Run Lane
  32. ;    Algonquin, Il   60102
  33. ;    (708) 658-4941
  34.  
  35.  
  36. ;------------------------------------------------------------------------
  37. COMMENT *
  38.  
  39.       Routine to modify diskette boot record, using drive A: or B:,
  40.       thus circumventing DOS' non-system disk display error.
  41.  
  42.       Usage:
  43.             BT A:       -> transfer new boot record to drive A:
  44.             BT B:       -> transfer new boot record to drive B:
  45.             BT           -> starts program, default is drive A:
  46. *
  47. ;------------------------------------------------------------------------
  48. code        SEGMENT BYTE PUBLIC 'code'
  49. ASSUME        CS:code,DS:code,SS:code
  50.         ORG    5Ch            ;drive id
  51. param1        LABEL    BYTE
  52.         ORG    5Dh            ;elim spurrious characters
  53. param2        LABEL    BYTE
  54.  
  55.         ORG    100h
  56.  
  57. BootThru    PROC    FAR
  58.         CALL    Chk_Ver         ;dos 2.0 or greater
  59.  
  60.         CALL    Scan
  61.         CALL    Dwrite
  62.         JMP    SHORT exit
  63. error:
  64.         CALL    Print            ;print error messages
  65.         MOV    AL,1            ;set errorlevel to 1
  66. exit:
  67.         MOV    AH,4Ch
  68.         INT    21h
  69.  
  70. ;------------------------------------------------------------------------
  71. ; Work Area - constants,equates,messages
  72. ;------------------------------------------------------------------------
  73. drive        DB    0
  74.  
  75. blank        EQU    020h        ;ascii space code
  76. cr        EQU    0Dh        ;carriage return
  77. lf        EQU    0Ah        ;line feed
  78. ch_esc        EQU    01Bh        ;escape char
  79. stopper     EQU    255        ;end of display line indicator
  80.  
  81. logo    DB    cr,lf,'BootThru - The Diskette Modifier--boot thru floppy to the hard disk'
  82.     DB    cr,lf,'Version 1.08 - Bill Gibson & Ray Van Tassle',cr,lf,stopper
  83.  
  84. usage    DB    cr,lf,'Usage: BT [drive A: or B:]',cr,lf
  85.     db    '  Modifies floppy boot sector to boot from drive C:',stopper
  86. sorry    DB    cr,lf,'Wrong PC DOS Version',cr,lf,stopper
  87. msg1    DB    cr,lf,'Insert diskette in drive '
  88. drive_letter    DB    ?
  89.     db    stopper
  90.     DB    ' and press ENTER when ready ...',stopper
  91. msg3    DB    cr,lf,'Press ENTER to modify another disk',cr,lf
  92.     DB    'or ESCape to quit...',stopper
  93. msg4    DB    cr,lf,cr,lf,'Transferring New Boot Sector',cr,lf,stopper
  94. msg5    DB    cr,lf,'Transfer Completed',cr,lf,stopper
  95.  
  96. msg80h    DB    cr,lf,cr,lf,'* Error *  Drive failed to respond.',cr,lf,cr,lf,stopper
  97. msg40h    DB    cr,lf,cr,lf,'* Error *  Seek operation failed.',cr,lf,cr,lf,stopper
  98. msg20h    DB    cr,lf,cr,lf,'* Error *  Controller failure.',cr,lf,cr,lf,stopper
  99. msg10h    DB    cr,lf,cr,lf,'* Error *  Bad CRC on diskette write.',cr,lf,cr,lf,stopper
  100. msg08h    DB    cr,lf,cr,lf,'* Error *  DMA overrun on operation.',cr,lf,cr,lf,stopper
  101. msg04h    DB    cr,lf,cr,lf,'* Error *  Requested sector not found.',cr,lf,cr,lf,stopper
  102. msg03h    DB    cr,lf,cr,lf,'* Error *  Write protected diskette.',cr,lf,cr,lf,stopper
  103. msg02h    DB    cr,lf,cr,lf,'* Error *  Address mark not found.',cr,lf,cr,lf,stopper
  104. msggen    DB    cr,lf,cr,lf,'* Unknown Error *',cr,lf,cr,lf,stopper
  105.  
  106. ;--------------------------------------------------------------------------
  107. ; Sub-Routines:
  108. ;--------------------------------------------------------------------------
  109. Chk_Ver     PROC    NEAR
  110.         MOV    AH,30h        ;verify DOS 2.0 or later
  111.         INT    21h
  112.         CMP    AL,2
  113.         JAE    SHORT chk_ok
  114.         MOV    DX,OFFSET sorry
  115.         JMP    error
  116. chk_ok:
  117.         RET
  118. Chk_Ver     ENDP
  119.  
  120. ;--------------
  121.  
  122. Scan        PROC    NEAR        ;check for any spurrious chars
  123.         MOV    AL,[param2]
  124.         CMP    AL,blank        ;anything ?
  125.         JNZ    shlp            ;yes, give error msg
  126. s1:
  127.         MOV    AL,[param1]    ;check for drive parameters
  128.         OR    AL,AL            ;anything ?
  129.                 JZ      shlp                 ;no -
  130.         CMP    AL,01            ;setup for drive A:
  131.         JZ    SHORT sdrvOk
  132.         CMP    AL,02            ;for drive B:
  133.         JZ    SHORT sdrvOk
  134. shlp:
  135.         MOV    DX,OFFSET usage     ;display for invalid drives
  136.         JMP    error
  137. sdrvOk:
  138.         SUB    AL,1            ;remember the drive.
  139. sdrvDef:
  140.         MOV    drive,AL
  141.         ADD    AL,'A'
  142.         MOV    drive_letter,AL
  143.         MOV    DX,OFFSET logo
  144.         CALL    Print
  145.         MOV    DX,OFFSET msg1
  146.         RET
  147.  
  148. Scan        ENDP
  149.  
  150. ;--------------
  151.  
  152. Dwrite        PROC    NEAR        ;transfer new disk boot sector
  153.  
  154.         CALL    Print        ;get ready
  155. d1:    jmp d2
  156.         MOV    AH,8        ;use function 8 in order to detect
  157.         INT    21h        ;ctrl-breaks
  158.         CMP    AL,ch_esc    ;ESC & Ctrl-Break aborts process
  159.         JZ    d5
  160.         CMP    AL,cr
  161.         JNZ    d1
  162. d2:
  163.         MOV    DX,OFFSET msg4        ;setup for disk write
  164.         CALL    Print
  165.  
  166.         MOV    AL,drive        ;read the old boot sector.
  167.         LEA    BX,oldBoot
  168.         MOV    CX,0001
  169.         MOV    DX,0000
  170.  
  171.         PUSH    AX
  172.         PUSH    BX
  173.         PUSH    CX
  174.         PUSH    DX
  175.         INT    25h
  176.         JC    derror            ;processing error ?
  177.         POPF                ;done
  178.         POP    DX
  179.         POP    CX
  180.         POP    BX
  181.         POP    AX
  182.  
  183.         MOV    SI,OFFSET oldBoot+3+8    ;transfer the old bios parameters block.
  184.         MOV    DI,OFFSET head+3+8    ;into the new sector.
  185.         MOV    CX,OFFSET end_bpb
  186.         SUB    CX,DI
  187.         REP    MOVSB
  188.  
  189.         MOV    AL,drive
  190.         LEA    BX,head
  191.         MOV    CX,0001
  192.         MOV    DX,0000
  193.         PUSH    AX
  194.         PUSH    BX
  195.         PUSH    CX
  196.         PUSH    DX
  197.         INT    26h
  198.         JC    derror            ;processing error ?
  199.         POPF                ;done
  200.         POP    DX
  201.         POP    CX
  202.         POP    BX
  203.         POP    AX
  204. d3:
  205.         MOV    DX,OFFSET msg5        ;transfer complete
  206.         CALL    Print
  207.         JMP    d4
  208. derror:                     ;display disk errror
  209.         CALL    ErrorList
  210. dend_of:
  211.         CALL    Print
  212.         POPF                ;done
  213.         POP    DX
  214.         POP    CX
  215.         POP    BX
  216.         POP    AX
  217. d4:
  218.         jmp    d5
  219.         MOV    DX,OFFSET msg3        ;another ?
  220.         CALL    Print
  221.         JMP    d1            ;loop
  222. d5:
  223.         RET
  224. Dwrite        ENDP
  225.  
  226. ;--------------
  227.  
  228. Print        PROC    NEAR        ;a Great idea from Vern Buerg !
  229.         PUSH    SI
  230.         PUSH    BX
  231.         PUSH    CX
  232.         MOV    SI,DX        ;DX has the offset to string
  233.         SUB    CX,CX        ;set to zero for count
  234. p1:
  235.         LODSB
  236.         CMP    AL,stopper    ;string ends in FFh
  237.         JE    p9
  238.         INC    CX        ;increment text length
  239.         JMP    p1
  240. p9:
  241.         MOV    AH,40h        ;write using file handles
  242.         MOV    BX,1
  243.         INT    21h
  244.         POP    CX
  245.         POP    BX        ;recover registers
  246.         POP    SI
  247.         RET
  248. Print        ENDP
  249.  
  250. ;--------------
  251.  
  252. ErrorList    PROC    NEAR        ;error code interpretation
  253.                     ;the upper byte (AH) contains error
  254. err80h:     CMP    AH,080h         ;attachment failed to respond
  255.         JNZ    err40h
  256.         MOV    DX,OFFSET msg80h
  257.         RET
  258. err40h:
  259.         CMP    AH,040h         ;seek operation failed
  260.         JNZ    err20h
  261.         MOV    DX,OFFSET msg40h
  262.         RET
  263. err20h:
  264.         CMP    AH,020h         ;controller failed
  265.         JNZ    err10h
  266.         MOV    DX,OFFSET msg20h
  267.         RET
  268. err10h:
  269.         CMP    AH,010h         ;data error (bad CRC)
  270.         JNZ    err08h
  271.         MOV    DX,OFFSET msg10h
  272.         RET
  273. err08h:
  274.         CMP    AH,08h            ;direct memory access failure
  275.         JNZ    err04h
  276.         MOV    DX,OFFSET msg08h
  277.         RET
  278. err04h:
  279.         CMP    AH,04h            ;requested sector not found
  280.         JNZ    err03h
  281.         MOV    DX,OFFSET msg04h
  282.         RET
  283. err03h:
  284.         CMP    AH,03h            ;write-protect fault
  285.         JNZ    err02h
  286.         MOV    DX,OFFSET msg03h
  287.         RET
  288. err02h:
  289.         CMP    AH,02h            ;bad address mark
  290.         JNZ    errgen
  291.         MOV    DX,OFFSET msg02h
  292.         RET
  293. errgen:
  294.         MOV    DX,OFFSET msggen    ;something new ?  (Unknown)
  295.         RET
  296. ErrorList    ENDP
  297.  
  298. ;--------------
  299.  
  300. ;the new boot sector starts here.
  301. head:
  302. cr        EQU    0Dh        ;carriage return
  303. lf        EQU    0Ah        ;line feed
  304. stopper     EQU    255        ;end of display line indicator
  305. boot_area    EQU    0000h        ;setup boot area
  306. hard_drv    EQU    0080h        ;setup hard drive
  307. loc2        EQU    01FEh        ;last two bytes of boot sector
  308. eof_bootsec    EQU    0AA55h        ;end of boot sector (reversed)
  309. bulc        EQU    0DAh        ;box upper left corner
  310. burc        EQU    0BFh        ;box upper right corner
  311. bllc        EQU    0C0h        ;box lower left corner
  312. blrc        EQU    0D9h        ;box lower right corner
  313. bver        EQU    0B3h        ;vertical
  314. bhor        EQU    0C4h        ;horizontal
  315.  
  316.         JMP    startx        ;1st byte of the sector must be a jmp
  317.         DB    'BootThru'      ;8-byte system id
  318.         DW    512        ;sector size in bytes
  319.         DB    2        ;sectors per cluster
  320.         DW    1        ;reserved clusters
  321.         DB    2        ;number of fats
  322.